package com.ityls.springsecuritystudy.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

// Security配置类
// @Configuration
public class SecurityConfig_bak1 {
    // 定义认证逻辑
    // @Bean
    // public UserDetailsService userDetailsService(){
    //     // 1.使用内存数据进行认证
    //     InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
    //
    //     // 2.创建两个用户
    //     UserDetails user1 = User.withUsername("malu").password("123").authorities("admin").build();
    //     UserDetails user2 = User.withUsername("ityls").password("123").authorities("admin").build();
    //
    //     // 3.将这两个用户添加到内存中
    //     manager.createUser(user1);
    //     manager.createUser(user2);
    //
    //     return manager;
    // }

    //密码编码器，不解析密码
    // @Bean
    // public PasswordEncoder passwordEncoder(){
    //     return NoOpPasswordEncoder.getInstance();
    // }

    //密码编码器
    @Bean
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }
}
